package com.ruoyi.jpmf.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jpmf.domain.common.Mfjixieapp;
import com.ruoyi.jpmf.service.IMfjixieappService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 机械进场Controller
 * 
 * @author hxy
 * @date 2020-02-20
 */
@Controller
@RequestMapping("/jixieapp/jixieapp")
public class MfjixieappController extends BaseController
{
    private String prefix = "jixieapp/jixieapp";

    @Autowired
    private IMfjixieappService mfjixieappService;

    @RequiresPermissions("jixieapp:jixieapp:view")
    @GetMapping()
    public String jixieapp()
    {
        return prefix + "/jixieapp";
    }

        /**
     * 查询机械进场列表
     */
    @RequiresPermissions("jixieapp:jixieapp:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Mfjixieapp mfjixieapp)
    {
        startPage();
        List<Mfjixieapp> list = mfjixieappService.selectMfjixieappList(mfjixieapp);
        return getDataTable(list);
    }
    
    /**
     * 导出机械进场列表
     */
    @RequiresPermissions("jixieapp:jixieapp:export")
    @Log(title = "机械进场", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Mfjixieapp mfjixieapp)
    {
        List<Mfjixieapp> list = mfjixieappService.selectMfjixieappList(mfjixieapp);
        ExcelUtil<Mfjixieapp> util = new ExcelUtil<Mfjixieapp>(Mfjixieapp.class);
        return util.exportExcel(list, "jixieapp");
    }

    /**
     * 新增机械进场
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存机械进场
     */
    @RequiresPermissions("jixieapp:jixieapp:add")
    @Log(title = "机械进场", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Mfjixieapp mfjixieapp)
    {
        return toAjax(mfjixieappService.insertMfjixieapp(mfjixieapp));
    }

    /**
     * 修改机械进场
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        Mfjixieapp mfjixieapp = mfjixieappService.selectMfjixieappById(id);
        mmap.put("mfjixieapp", mfjixieapp);
        return prefix + "/edit";
    }

    /**
     * 修改保存机械进场
     */
    @RequiresPermissions("jixieapp:jixieapp:edit")
    @Log(title = "机械进场", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Mfjixieapp mfjixieapp)
    {
        return toAjax(mfjixieappService.updateMfjixieapp(mfjixieapp));
    }

    /**
     * 删除机械进场
     */
    @RequiresPermissions("jixieapp:jixieapp:remove")
    @Log(title = "机械进场", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(mfjixieappService.deleteMfjixieappByIds(ids));
    }
}
